﻿using _12.享元模式.Base;
using _12.享元模式.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _12.享元模式
{
    internal class Client
    {
        public void Start()
        {
            PieceFactory factory = PieceFactory.Instance;

            Piece piece1 = factory.GetPiece("黑");
            Piece piece2 = factory.GetPiece("黑");

            Piece piece3 = factory.GetPiece("白");
            Piece piece4 = factory.GetPiece("白");
            Piece piece5 = factory.GetPiece("白");

            piece1.Display(new System.Drawing.Point(10, 200));
            piece2.Display(new System.Drawing.Point(54, 87));
            piece3.Display(new System.Drawing.Point(66, 77));
            piece4.Display(new System.Drawing.Point(88, 99));
            piece5.Display(new System.Drawing.Point(139, 199));

            Console.WriteLine($"{piece1 == piece2}");
            Console.WriteLine($"{piece3 == piece4}");
            Console.WriteLine($"{piece4 == piece5}");
            Console.WriteLine($"{piece1 == piece3}");
            Console.WriteLine($"hashtable中元素数量：{factory.hashtable.Count}");

        }
    }
}
